package com.xd.study.utility;

import android.app.Service;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;

import java.io.FileDescriptor;

/**
 * Created by DGF on 2015/5/5.
 */
public class MyBindService extends Service {

    @Override
    public void onCreate() {
        Log.i("service", "onCreate");
        super.onCreate();
    }

    /**
     * 自定义Binder
     */
    public class MyBinder extends Binder{

        public MyBindService getService(){
            return MyBindService.this;
        }
    }

    /**
     * 需要自定义Binder类，作为返回值
     * @param intent
     * @return
     */
    @Override
    public IBinder onBind(Intent intent) {
        Log.i("service", "onBind");
        return new MyBinder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("service", "onUnbind");
        return super.onUnbind(intent);
    }

    @Override
    public void unbindService(ServiceConnection conn) {
        Log.i("service", "unbindService");
        super.unbindService(conn);
    }

    @Override
    public void onDestroy() {
        Log.i("service", "onDestroy");
        super.onDestroy();
    }

    public void play(){
        Log.i("service", "Play");
    }

    public void pause(){
        Log.i("service", "Pause");
    }

    public void previous(){
        Log.i("service", "Previous");
    }

    public void next(){
        Log.i("service", "Next");
    }
}
